package com.runa.monitor.platinterface.dispatch.conn;

import com.runa.monitor.platinterface.dispatch.grpcComm.EmptyComm;
import io.grpc.stub.StreamObserver;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class LoginStreamResponse implements StreamObserver<EmptyComm> {

    private Client client;

    public LoginStreamResponse(Client client) {
        this.client = client;
    }

    @Override
    public void onNext(EmptyComm emptyComm) {

    }

    @Override
    public void onError(Throwable throwable) {
        log.error("node login error: {}", throwable.getMessage());
        this.client.delayLogin();
    }

    @Override
    public void onCompleted() {
        log.info("node login success !");
        this.client.chatFlowEntryUnit();
    }
}
